home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
LIBRARY
/
SWDOS12
/
TEXTSEEK.ASM
< prev
next >
Wrap
Assembly Source File
|
1995-02-10
|
2KB
|
71 lines
;******************************************************************
;* TEXTSEEK.ASM *
;* Source file for SoftWeyr enhanced DOS toolbox *
;* version 1.1 *
;* Copyright (c) by SoftWeyr,1994 *
;******************************************************************
MODEL TPASCAL
include textrec.asm
.DATA
EXTRN InOutRes:Word
.CODE
PUBLIC TextSeek
TextSeek Proc far F:DWORD,Target:DWORD
LOCAL Pos : DWORD
LES DI,F
CMP ES:[DI].TextRec.Mode,fmInput
JZ @@1
MOV InOutRes,104;
RET
@@1:
Mov AX,4201H; {move file pointer function}
LES DI,F
MOV BX,ES:[DI].TextRec.Handle[0]; {file handle}
Sub CX,CX; {if CX and DX are both 0, call returns the..}
MOV DX,CX;
;{current file pointer in DX:AX}
INT 21H
JNC @@2;
;{check for I/O error}
MOV InOutRes,AX
JMP @@3
@@2: Mov Word Ptr Pos[2],DX
MOV Word ptr Pos[0],AX
MOV InOutRes,0
@@3: CMP InOutRes,0
JZ @@4
RET
@@4: MOV AX,Word Ptr Pos[0]
SUB AX,ES:[DI].TextRec.BufEnd
MOV Word Ptr Pos[0],AX
JNC @@5
DEC Word Ptr Pos[2]
@@5: ;{see if the Target is within the buffer}
MOV AX,Word Ptr Target[0]
SUB AX,Word Ptr Pos[0]
MOV DX,Word Ptr Target[2]
SBB DX,Word Ptr Pos[2]
CMP DX,0
JNZ @@6
CMP AX,0
JL @@6
CMP AX,ES:[DI].TextRec.BufEnd
JG @@6
MOV ES:[DI].TextRec.BufPos,AX
JMP SHORT @@8
@@6: MOV AX,4200H; {move file pointer function}
MOV BX,ES:[DI].TextRec.Handle; {file handle}
MOV CX,Word ptr Target[2]; {CX has high word of Target offset}
MOV DX,Word ptr Target[0]; {DX has low word}
INT 21H
JNC @@7
MOV InOutRes,AX
JMP @@8
@@7: MOV InOutRes,0
MOV ES:[DI].TextRec.BufEnd,0;
MOV ES:[DI].TextRec.BufPos,0;
@@8: RET;
endp
end